package ui.adapter;

import android.graphics.Color;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fy.fyzf.R;
import com.fy.fyzf.bean.AreaListBean;

import ui.fragment.HouseResouceFragment;

public class AreaListAdapter extends BaseQuickAdapter<AreaListBean, BaseViewHolder> {


    public AreaListAdapter() {
        super(R.layout.item_area_filter);
    }

    private int currPos = 0;
    public void setSelect(int i){
        currPos = i;
        notifyDataSetChanged();
    }

    public Integer getSelectId(){
        if (getData().size() > 0) {
            if (currPos >0) {
                return getData().get(currPos).getId();
            }
            return 0;
        } else {
            return 0;
        }
    }

    public String getSelectName(){
        if (getData().size() > 0) {
            if (HouseResouceFragment.cityType == 1) {
                return getData().get(currPos).getName();
            } else {
                return getData().get(currPos).getSubwayName();
            }

        } else {
            return "0";
        }
    }
    @Override
    protected void convert(BaseViewHolder helper, AreaListBean item) {

        if (HouseResouceFragment.cityType == 1) {
            helper.setText(R.id.tv_name, item.getName());
        } else {
            helper.setText(R.id.tv_name, item.getSubwayName());
        }
        TextView textView = helper.getView(R.id.tv_name);
        if (currPos == helper.getAdapterPosition()) {
            textView.setTextColor(mContext.getResources().getColor(R.color.color_theme));
        } else {
            textView.setTextColor(Color.BLACK);
        }
    }
}
